﻿using System;
using System.Linq;
using System.Data.Linq;

namespace TempEmployees.DAL
{
    partial class Assignment
    {
        public Assignment PrevAssignment
        {
            get
            {
                TempEmpDatabaseDataContext db = new TempEmpDatabaseDataContext();
                var query = db.Assignments.Where(a => a.ID == PrevAssignmentID);
                return (query.Count() > 0) ? query.First() : null;
            }
        }

        public bool SetSalary(bool isStudentSalary, decimal salary)
        {
            if (isStudentSalary) Salary = 0;
            else if (salary > 0) Salary = salary;
            else return false;
            return true;
        }

        public void ClearBudget()
        {
            _Budget = default(EntityRef<Budget>);
        }
    }
}
